package com.szbber.commen.base

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.utils.ThreadPoolUtils
import com.blankj.utilcode.utils.Utils
import com.szbber.commen.utils.DataStoreUtil
import com.szbber.commen.utils.PreferUtil
import com.szbber.medical.commen.BuildConfig

open class BaseApplication :Application(){

    companion object {

        @SuppressLint("StaticFieldLeak")
        private var mContext: Context? = null

        @SuppressLint("StaticFieldLeak")
        private var instance: BaseApplication? = null

        var MAIN_EXECUTOR = ThreadPoolUtils(ThreadPoolUtils.Type.FixedThread, 20)

        fun getContext(): Context? {
            return mContext
        }

        fun getInstance(): BaseApplication? {
            return instance
        }

    }

    override fun onCreate() {
        super.onCreate()
        initARouter()
        Utils.init(this)
        DataStoreUtil.instance.init(this)
        PreferUtil.init(this)
    }

    private fun initARouter() {
        if (BuildConfig.DEBUG){
            ARouter.openLog()
            ARouter.openDebug()
        }
        ARouter.init(this)
    }


}